package huawei.exam1;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author : Rookie
 * @description : 合并表记录
 * @date : 2022/12/16
 */
public class HJ8 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
            int count = scanner.nextInt();
            Map<Integer, Integer> hashMap = new HashMap<>(count);
            for (int i = 0; i < count; i++) {
                int key = scanner.nextInt();
                int val = scanner.nextInt();
                if (hashMap.containsKey(key)) {
                    hashMap.put(key,hashMap.get(key) + val);
                } else {
                    hashMap.put(key,val);
                }
            }

            for (Map.Entry<Integer,Integer> entry : hashMap.entrySet()) {
                System.out.println(entry.getKey() + " " + entry.getValue());
            }
        }
}
